home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / CollView.h < prev    next >
C/C++ Source or Header  |  1992-07-16  |  3KB  |  110 lines

  1. #ifndef CollView_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define CollView_First
  7.  
  8. #include "View.h"
  9.  
  10. class SeqCollection;
  11.  
  12. //---- CollectionView options --------------------------------------------------
  13.  
  14. enum CollViewOptions {
  15.     eCVGrid             = BIT(eViewLast+1),
  16.     eCVDontStuckToBorder= BIT(eViewLast+2),
  17.     eCVExpandRows       = BIT(eViewLast+3),
  18.     eCVExpandCols       = BIT(eViewLast+4),
  19.     eCVModified         = BIT(eViewLast+5),
  20.     eCVDefault          = 0,
  21.     eCVLast             = eViewLast + 5
  22. };
  23.  
  24. //---- CollectionView ----------------------------------------------------------
  25.  
  26. class CollectionView: public View {
  27. protected:
  28.     SeqCollection *coll;
  29.     Rectangle selection;
  30.     Point gap, minExtent;
  31.     int *xPos, *yPos, rows, cols;
  32.     VObject *defaultItem;
  33.  
  34. public:
  35.     MetaDef(CollectionView);
  36.  
  37.     CollectionView(EvtHandler*, SeqCollection*, CollViewOptions o= eCVDefault,
  38.                                int r= 0, int c= 1);
  39.     ~CollectionView();
  40.  
  41.     void SetCollection(SeqCollection*, bool freeold= TRUE);
  42.     SeqCollection *GetCollection()
  43.     { return coll; }
  44.     void SetDefaultItem(VObject *d);
  45.     void SetColsRows(Point cr);
  46.  
  47.     //---- layout
  48.     void SetMinExtent(Point);
  49.     Metric GetMinSize();
  50.     void SetOrigin(Point at);
  51.     void SetGap(Point g)
  52.     { gap= g; }
  53.     void Update();
  54.     void Open(bool m);
  55.     
  56.     //---- drawing
  57.     void Draw(Rectangle);
  58.     virtual void DrawGrid(Point from, Point to);
  59.     
  60.     //---- event handling
  61.     Command *DoLeftButtonDownCommand(Point, Token, int);
  62.     Command *DoKeyCommand(int, Token);
  63.     virtual void DoSelect(Rectangle sel, int clicks);
  64.     VObject *Detect(BoolFun find, void *arg);
  65.  
  66.     //---- updating (change propagation)
  67.     void DoObserve(int, int, void*, Object*);
  68.     void Modified();
  69.     
  70.     //---- selection
  71.     Rectangle GetSelection()
  72.     { return selection; }
  73.     void SetSelection(Rectangle, bool sendcontrol= FALSE);
  74.     void ClearSelection(bool redraw= TRUE);
  75.     
  76.     //---- mapping
  77.     Point PointToItem(Point, bool *outside= 0);
  78.     Rectangle ItemRect(int, int);
  79.     VObject *GetItem(int x, int y);
  80.     Point ItemPos(VObject *);
  81.     Rectangle ItemRect(Rectangle r);
  82.     void InvalidateItemRect(Rectangle r)
  83.     { InvalidateRect(ItemRect(r)); }
  84.     void ConstrainScroll(Point*);
  85.  
  86.     //---- input/output
  87.     OStream& PrintOn(OStream&);
  88.     IStream& ReadFrom(IStream&);
  89.     bool PrintOnWhenObserving(Object*);
  90.     
  91.     //---- inspecting
  92.     void CollectParts(Collection*);
  93. };
  94.  
  95. //---- CellSelector ------------------------------------------------------------
  96.  
  97. class CellSelector: public Command {
  98.     CollectionView *lvp;
  99.     VObject *itemptr, *last;
  100.     Point item;
  101.     bool dontstuck;
  102. public:
  103.     CellSelector(CollectionView*, bool dontstucktoborder);
  104.     void TrackFeedback(Point, Point, bool);
  105.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  106. };
  107.  
  108. #endif
  109.  
  110.